#pragma once
#include "psyche.h"
#include "MsgTemplate.h"
#include "MsgProtocol.h"

namespace cupid
{
class NetMsg
{
public:
	NetMsg(void);
	virtual ~NetMsg(void);
	void	init(void);
	void	reset(void)	{init();}

	const unsigned short	getType	(void)		{return m_msgType;}
	const unsigned short	getSize	(void)		{return m_msgSize;}

	char*	getBuf(void)	{return m_bufMsg;}

public:	
	virtual BOOL			create (char* msgBuf, DWORD dwSize);
	virtual BOOL			isValid		(void);
	virtual void			send		(void);
	virtual void			process (void *info);

public:
	static int	getMaxSize	(void)		{return _MAX_MSGSIZE;}
	static unsigned short	getType		(char* bufMsg, DWORD dwMsgSize);
	static unsigned short	getSize		(char* bufMsg, DWORD dwMsgSize);

	static NetMsg* createMsg (char* bufMsg, DWORD dwMsgSize);

protected:
	union {
		char	m_bufMsg[_MAX_MSGSIZE];
		struct {
			unsigned short	m_msgSize;
			unsigned short	m_msgType;
		};
	};
};
}